Before we end this course, I want to show you a tool that you can use to boost your productivity in
Roblox Studio substantially.
This tool is called Chat GPT and you've probably heard about it before, but if not chat.
GPT is an AI where you can input text and it can respond back to you like a human.
It can write essays for you, tell jokes, explain information on a particular topic and much more.
How can we use chat GPT for scripting?
Well, chat GPT has the ability to write, review, improve and fix code for you, including the Lua
use scripting language.
This means if you ever encounter an error in your code that you do not know how to fix and could not
find the answer for or you need help understanding a section in code or you just need to improve your
code chat.
GPT is a must use tool for you.
We can go to chat dot open wacom to use this tool and you'll have to create an account to use it.
But after you do that, you should be greeted by this screen where you can enter in a prompt.
There is also a desktop application that you can use for this tool as well, and I'll have it attached
to this lecture.
So to demonstrate chat gifts, code creation abilities here, I'm going to input some text and I want
change GPT to create a function for me in Lilliput that takes a base part and moves that base part ten
studs forward in the direction it's facing.
So it can ask it and say something like, Hey, chat GPT can you write me a function in lieu of you
that takes a bass part and moves the bass parts?
See frame ten studs forward and the direction it's facing.
Let's see what chat GPT generates for us.
That's
pretty impressive, right?
Obviously, there's a little bit of an issue here.
I don't really know what the purpose of this section is, because this will move the sea frame and whatever
direction the C frame of the part is looking.
But as you can see, GPT has created some code for us that should work.
Now, if you're confused with anything in this code, well you can ask GPT to explain it for you because
this I can remember all the previous conversations that you've had in this particular chat.
For example, let's say I didn't know what type annotations were, and I don't know exactly what this
colon based part is doing here in the function.
That means I can ask Chat GP to explain it to me.
I can say, Hey, chat GPT what does colon base part?
Mean in the parameter section of the move.
Part forward function.
Let's see what it tells us.
And as you can see here, chat.
GPT has fully explained to us what the purpose of those lines were in great detail.
It's telling us that this part that is being passed to this function is expected to be of the class
base part.
And it is telling us it is a type hint or a type annotation.
It's not a requirement, but it helps us to improve the readability and maintainability of our code.
You might now start to see the absolute power of this tool can have for you as a scripter and boosting
your productivity.
Let's give chat GPT a little bit more of a challenge.
Let's ask it to do something more complicated like recasts so I can say something like.
Hey chat GPT write me.
A function in lua you that has to parameters.
A bass part and a number.
Using these two parameters.
Have the function fire array cast in the direction of where.
The base part is facing with the length defined by the number parameter.
If this rate cast hits a part, print the name of the part.
Let's see if Chat can do that for us.
All right.
This is very nice.
It has generated some code for us for recasting.
And it is also told us that it's ignoring the part where we are shooting this Ray Cas from.
But there is a little bit of an issue and it's that these functions.
And creating a new REA data type is deprecated.
It's better to use the workspace recast function and use the recast parameters data type instead.
Because these are deprecated, you don't want to use them for new work.
So let's ask GPT to fix this for us because we don't want to use deprecated features we can say.
Thanks chat GPT but unfortunately.
Ray dot new.
And find part on Ray is deprecated.
Can you use recast params and workspace recast instead?
We'll see if it'll do that.
Okay, so it fixed one part of the section, but I don't think chat gpt fully understood what I mean
because we still don't want to use robot new here.
We don't need to.
This is deprecated and we only need to use the base part.
So let's ask GPT one more time to get rid of this deprecated feature.
As you can tell, this is quite incredible.
So GPT has created us an up to date function that uses non deprecated features on array casting in the
direction that a part is facing with a distance of 20 studs as it has given our example here.
And it explains all the important details of this function.
So as you can see, this is very useful.
But not only can it generate code for you, but it can also fix errors for you.
So I'm going to create some code with a syntax error in it real quick and let's see if GPT can fix our
problem.
So I've written some code that's going to obviously error and I'm going to ask GPT to help me fix this
error.
So I'm going to tell chat GPT hey chat GPT.
I have an error in my code where it is telling me that dot c frame is not a valid property for this
variable I am grabbing from the workspace.
Can you help me out and we'll paste the code down here.
So what my code is, is we're getting a variable called part and we're finding the first child on the
workspace that is a model and obviously a model doesn't have a C frame property, so we can't update
the C frame of the model and this might return nil as well because there is no guarantee that we have
a model in the workspace.
But that's why I've added this if statement here.
So it shouldn't check for that.
It should just tell us that C frame is not a valid property of a part because it's a model.
So let's see what chat GPT tells us.
Wow.
Very impressive.
And it gives us a very detailed rundown of different alternative things we can do for a model such as
moving the position property or moving all of the parts in the model by this vector.
It explains to us exactly why we were having this error and how we could solve this problem.
So Chad, GPT is an extremely powerful tool for scripts.
It should improve your productivity greatly and I'd really recommend for you to use it.